// MonitorController.java
package com.example.monitor.controller;

import com.example.monitor.model.VO.CameraVO;
import com.example.monitor.model.VO.ResultVO;
import com.example.monitor.service.CameraService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/monitor")
@RequiredArgsConstructor
public class MonitorController {

    private final CameraService cameraService;

    @GetMapping("/cameras")
    public ResultVO<List<CameraVO>> getCameraList() {
        return cameraService.getAllCameras();
    }
    
    // 新增摄像头
    @PostMapping("/cameras")
    public ResultVO<CameraVO> addCamera(@RequestBody CameraVO cameraVO) {
        return cameraService.addCamera(cameraVO);
    }
    
    // 更新摄像头信息
    @PutMapping("/cameras/{cameraId}")
    public ResultVO<CameraVO> updateCamera(
            @PathVariable Long cameraId,
            @RequestBody CameraVO cameraVO) {
        return cameraService.updateCamera(cameraId, cameraVO);
    }
    
    // 删除摄像头
    @DeleteMapping("/cameras/{cameraId}")
    public ResultVO<Void> deleteCamera(@PathVariable Long cameraId) {
        return cameraService.deleteCamera(cameraId);
    }
}
